from flask.json import jsonify


class Result:
    """统一响应结果类，支持链式调用"""

    @staticmethod
    def success(msg="操作成功", data=None):
        """成功响应"""
        return jsonify({
            "code": 0,
            "msg": msg,
            "data": data or {}
        })

    @staticmethod
    def error(msg="操作失败", data=None):
        """错误响应"""
        return jsonify({
            "code": 1,
            "msg": msg,
            "data": data or {}
        })
